#include <iostream>
#include <cstdlib>
#include "swf.h"

#include "Rect.h"
#include "Bits.h"
using namespace swfstream;
void Rect::print() {
//	exit(1);
	std::clog << "rect(" << (int) n_bits << "," << (int) x_min << ","
			<< (int) x_max << "," << (int) y_min << "," << (int) y_max << ")\n";
}

Rect* Rect::from_file(FILE* f) {
	long s = ftell(f);
	//puts("reading rect");
	Rect *r = new Rect;
	Bits bits;
	//	bits.reset();
	r->n_bits = bits.read_u(5, f);
	//uint bits=read_bits(5,f);
	r->x_min = bits.read_s(r->n_bits, f);
	r->x_max = bits.read_s(r->n_bits, f);
	r->y_min = bits.read_s(r->n_bits, f);
	r->y_max = bits.read_s(r->n_bits, f);
	//	reset_bits();
	//printf("length of rect:%ld\n",ftell(f)-s);
	return r;
}
